home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus Leser 15
/
Amiga Plus Leser CD 15.iso
/
Games
/
Centipede
/
Centipede.Bak
/
Centipede.amosSourceCode
< prev
next >
Wrap
AMOS Source Code
|
2002-03-13
|
10KB
|
576 lines
Rem *** CENTIPEDE DX ***
Rem *** MILLENNIUM EDITION ***
Rem (c) 1999 by Norman Walter
Dim X(20),Y(20),SPEED(20),CLIMB(20),HITPOINTS(20),NAME$(9),SCORE(9)
Global X(),Y(),S,MUSHROOMS,SPEED(),CLIMB(),ELEMENTS,HITPOINTS(),ALLHITPOINTS,Z
Global LIVES,SCORE,SCORE(),NAME$(),GAMEMODE$,HSC$
HSC$="Centipede_Hiscore"
Make Mask
HISCORE_LOAD[HSC$]
GAMEMODE$="NORMAL"
Do
TITLE
MAINLOOP
Loop
Procedure MAINLOOP
If GAMEMODE$="EASY"
S=2 : MUSHROOMS=1
End If
If GAMEMODE$="NORMAL"
S=4 : MUSHROOMS=2
End If
If GAMEMODE$="HARD"
S=4 : MUSHROOMS=4
End If
LIVES=3 : SCORE=0
ELEMENTS=6 : Rem Anzahl der Elemente des Wurms
While LIVES>0
INIT
GAMELOOP
If ELEMENTS<15 Then Inc ELEMENTS
Wend
Rem *** Game Over ***
Bob Off : Sprite Off
Wait Vbl
Load Iff "GAME_OVER.iff",0
MWAIT[300]
HISCORE_ENTER[SCORE]
HISCORE_SAVE[HSC$]
End Proc
Procedure INIT
Screen Open 0,320,256,32,Lowres
Curs Off : Flash Off : Hide
Get Bob Palette : Cls 0
Limit Mouse 136,257 To 440,291
GIRD
Double Buffer
Synchro Off
Update Off
I=ELEMENTS*16 : Rem Anfangsposition des Kopfs
ALLHITPOINTS=0
W$="Anim 0,(7,4)(8,4)(7,4)(9,4)"
W$=W$+"Start:"
W$=W$+"Let X=R0;Let Y=R1"
W$=W$+"Jump Start"
Rem Anfangspositionen der Elemente
For E=1 To ELEMENTS
Add I,-16
HITPOINTS(E)=2
Add ALLHITPOINTS,2
SPEED(E)=S
CLIMB(E)=16
X(E)=I
Y(E)=8
Bob E,X(E),Y(E),1
Channel E To Bob E
Amal E,W$
Amal On E
Next E
HITPOINTS(1)=1 : Rem Kopf des Wurms
Dec ALLHITPOINTS
CHANGEHEAD[1]
End Proc
Procedure GAMELOOP
While LIVES>=1 and ALLHITPOINTS>0
ESCAPE
GUN
CRASH : Rem Kollisionsabrage
WORMMOVE
Synchro
Update
Wait Vbl
DISPLAY
Wend
End Proc
Procedure GIRD
Reserve Zone 320
Z=1
For Y=0 To 240 Step 16
For X=0 To 304 Step 16
Rem Ink 1 : Box X,Y To X+16,Y+16
If Y>16 and Y<208 and Rnd(20/MUSHROOMS)=1
Rem Set Zone Z,X,Y To X+16,Y+16 : Inc Z
Paste Bob X,Y,3
End If
Next X
Next Y
End Proc
Procedure WORMMOVE
For E=1 To ELEMENTS
Rem *** Bedingungen zum Umkehren ***
Add X(E),SPEED(E)
TURN=X(E)>=312 or X(E)<=0 or Point(X(E)+7,Y(E))=10 or Point(X(E)-7,Y(E))=10 : Rem or Zone(X(E),Y(E))<>0
EDGE=Y(E)>248 or Y(E)<8
If Bob Col(E,1 To ELEMENTS)<>0
Rem CLIMB(E)=-CLIMB(E)
Rem Add Y(E),CLIMB(E)
End If
If EDGE
If Y(E)>284 : CLIMB(E)=-16 : End If
If Y(E)<8 : CLIMB(E)=16 : End If
TURN=True
End If
If TURN
SPEED(E)=-SPEED(E)
Add Y(E),CLIMB(E)
If HITPOINTS(E)=1
CHANGEHEAD[E]
End If
End If
If HITPOINTS(E)=0
Bob Off E : Amal Off E
End If
Rem *** Koordinaten des Segments an Amalregister �bergeben ***
If HITPOINTS(E)<>0
Amreg(E,0)=X(E) : Amreg(E,1)=Y(E)
End If
Next E
End Proc
Procedure CHANGEHEAD[E]
Rem *** Animationsrichtung des Kopfes �ndern ***
Amal Off E
If Sgn(SPEED(E))=1
W$="Anim 0,(10,4)(11,4)(10,4)(12,4)"
Else
W$="Anim 0,(13,4)(14,4)(13,4)(15,4)"
End If
W$=W$+"Start:"
W$=W$+"Let X=R0;Let Y=R1"
W$=W$+"Jump Start"
Amal E,W$
Amal On E
End Proc
Procedure DISPLAY
If Chanmv(0)=0 Then Sprite Off 0 : Rem Schuss Ausblenden
Bob 0,X Screen(X Mouse),Y Screen(Y Mouse),2
Synchro
Update
Wait Vbl
End Proc
Procedure CRASH
Rem *** Spieler ber�hrt? ***
If Bob Col(0)<>0
Boom
Dec LIVES
End If
If Chanmv(0)<>0
Rem *** Abfrage, ob Wurm getroffen ***
If Spritebob Col(0,1 To ELEMENTS)<>0
Sprite Off 0 : Rem *** Schuss Ausblenden ***
Boom
Add SCORE,100
Rem *** Welches Element wurde getroffen? ***
E=1 : While Not Col(E) : Inc E : Wend
Dec HITPOINTS(E) : Dec ALLHITPOINTS
Rem *** Neuer Pilz ***
Rem Ink 2 : Box X(E)-8,Y(E)-8 To X(E)+8,Y(E)+8
Rem Set Zone Z,X(E)-8,Y(E)-8 To X(E)+8,Y(E)+8 : Inc Z
Paste Bob X(E)-8,Y(E)-8,3
Rem *** Neue Position des neuen Kopfs ***
Add Y(E),CLIMB(E)
SPEED(E)=-SPEED(E) : Add X(E),Sgn(SPEED(E))*16
CHANGEHEAD[E]
End If
XS=X Screen(X Sprite(0)) : YS=Y Screen(Y Sprite(0))
Rem *** Pilz getroffen? ***
If Point(XS,YS)<>0 : Rem Hzone(X Sprite(0),Y Sprite(0))<>0
Sprite Off 0
Ink 0 : Bar XS-10,YS-2 To XS+10,YS+10
Inc SCORE
End If
End If
End Proc
Procedure GUN
If Mouse Key and Chanmv(0)=0
Channel 0 To Sprite 0
Sprite 0,X Mouse,Y Mouse-16,4
Amal 0,"Move 0,-256,32" : Amal On 0 : Shoot : Rem Pfeil mit Amal abschie�en
End If
End Proc
Procedure ESCAPE
If Asc(Inkey$)=27 Then End
End Proc
Procedure MWAIT[T]
Rem *** Wartet auf Mouseclick oder bis angegebene Zeit T erreicht ***
If T<>0 Then Timer=0
Repeat
If Asc(Inkey$)=27 Then End
Until Mouse Key or Timer=T
End Proc
Procedure HISCORE_DISPLAY
Dim C(16)
Load Iff "Hiscores.iff",0
Rem Screen Open 0,320,256,32,Lowres : Curs Off : Flash Off : Cls 0
Rem Get Bob Palette
Paper 0 : Auto View Off
Rem Flash 14,"(666,15)(FFF,10)"
Rem Pen 2 : Locate 0,0 : Centre "Highscores"
Rem Pen 4 : Locate 0,2 : Centre "Top 10"
' Display the 10 names using a FOR..NEXT loop
'
Ink 15,0,0
For I=0 To 9
YP=82+I*9
SCORE$=Mid$(Str$(SCORE(I)),2)
LS=Text Length(SCORE$)
Set Font SCH
Text 30,YP,Str$(I+1)+"."
Text 70,YP,NAME$(I)
Text 290-LS,YP,SCORE$
Next I
'
Wait Vbl : View
Auto View On
Rem Flash 14,"(666,15)(FFF,10)" : Paper 0
End Proc
Procedure HISCORE_ENTER[SCORE]
'
If SCORE>SCORE(9)
'
' Find the position of our new score in the table
POS=0
While SCORE<=SCORE(POS)
POS=POS+1
Wend
' Move the lower scores one place down
For I=9 To POS+1 Step -1
NAME$(I)=NAME$(I-1)
SCORE(I)=SCORE(I-1)
Next I
NAME$(POS)=""
SCORE(POS)=SCORE
'
HISCORE_DISPLAY
Pen 14 : Locate 0,4 : Centre "please enter your name !"
XC=100 : YC=60
'
' Display Cursor
Gosub CURSEUR
'
' Input the name using a REPEAT..UNTIL loop
Repeat
' Read keyboard
K$=Inkey$
K=Asc(K$)
L=Len(NAME$)
' Handle Backspace
If K=8 and L>0
DC=0
XC=XC-8
Text XC,YC," "
Gosub CURSEUR
NAME$=Left$(NAME$,L-1)
End If
' Handle cursor
If K>13 and L<15
DC=8
Ink 14 : Text XC,YC,K$
XC=XC+8
Gosub CURSEUR
NAME$=NAME$+K$
End If
'
' Repeat until a carriage return.
Until K=13
If Len(NAME$)=0 : NAME$="Mr Noname" : End If
' Put the new name into the NAME$ array
NAME$(POS)=NAME$
SCORE(POS)=SCORE
'
Rem Flash Off
'
End If
'
' Display final array, and return!
HISCORE_DISPLAY
'
Pop Proc
'
' Simulate a 'fake' text cursor using the DRAW command
CURSEUR:
Ink 14 : Draw XC,YC To XC+5,YC
Return
'
End Proc
Procedure HISCORE_LOAD[N$]
'
Request Off : On Error Goto FAILURE
'
' Open a simple sequential file
Open In 1,N$
' Read the names and scores from the disc
For I=0 To 9
Line Input #1,NAME$(I),SCORE$
SCORE(I)=Val(SCORE$)
Next I
' Close up the file
Close 1
'
SKIP:
Pop Proc
'
FAILURE:
Resume SKIP
'
End Proc
Procedure HISCORE_SAVE[HSC$]
Pen 14 : Locate 0,25 : Centre "Do you want to save Highscores ? (y/n)"
Repeat
K=Asc(Inkey$)
If K=110 Then Exit : Rem n
If K=121 Then Goto STORE : Rem y
Until K=110 or K=121
Locate 0,25 : Cline
Pop Proc
'
STORE:
Locate 0,25 : Cline
On Error Proc DISKERROR
Resume Label LEAVE
' Create a simple sequential file
Open Out 1,HSC$
' Write the names and scores to the new file
For I=0 To 9
Print #1,NAME$(I)
Print #1,Str$(SCORE(I))
Next I
' Close the file (ESSENTIAL!)
Close 1
'
LEAVE:
Pop Proc
End Proc
Procedure DISKERROR
FAILURE:
Rem *** The error handling routine
HELP:
Request Off
Auto View Off
Screen Open 2,640,150,16,Hires : Curs Off : Flash Off : Cls 0
Get Icon Palette
Rem Palette ,,,,,,,,,,,,,$F59,$59F,$FF
Screen Display 2,,100,,
Paste Icon 10,10,1
Pen 2 : Paper 0
Locate 35,1 : Print "Disk error"
If Errn=84
Locate 35,3 : Print "Disk is write protected."
Locate 35,4 : Print "Please slide tab to the open position."
End If
If Errn=93
Locate 35,3 : Print "No disk in drive."
Locate 35,4 : Print "Please re-insert your game-disk."
End If
Pen 14 : Locate 35,7 : Print "PRESS MOUSE BUTTON TO TRY AGAIN"
Pen 13 : Locate 35,9 : Print "PRESS ESC TO CANCEL"
Auto View On
'
Rem *** Wait for users choice
Repeat
K$=Inkey$ : K=Asc(K$)
F=Mouse Click
Until K=27 or F<>0
'
Rem *** remove error routine's screen
Screen Close 2
'
Rem *** Exit routine ***
If F<>0 Then Resume
Resume Label
'
End Proc
Procedure OPTIONS
Open In 1,"Options.Anim5"
L=Frame Load(1 To 10,1000)
Close
P=Frame Play(10,1,0)
Double Buffer
Do
P=10
For X=1 To 72
P=Frame Play(P,1)
Screen Swap
Wait 2
If X=1 or X=24 or X=48 or X=72
Repeat
If Mouse Key=1
If X=1 : GAMEMODE$="NORMAL" : End If
If X=24 : GAMEMODE$="EASY" : End If
If X=48 : GAMEMODE$="HARD" : End If
Pop Proc
End If
Until Mouse Key=2
End If
Next X
Loop
Erase 10
End Proc
Procedure TITLE
Do
Screen Open 0,320,256,4,Lowres
Curs Off : Flash Off : Hide : Cls 0
Open In 1,"Intro.Anim5"
L=Frame Load(1 To 10,1000)
Close
P=Frame Play(10,1,0)
Double Buffer
P=10
For X=1 To 4
P=Frame Play(P,1)
Screen Swap
MWAIT[100]
Next X
Fade 5
MWAIT[100]
Erase 10
For I=1 To 5
Load Iff "Wurm.iff",0
MWAIT[150]
Load Iff "centipede.iff",0
Paper 0 : Pen 10
Locate 0,25 : Centre "press left mouse key to start"
Locate 0,27 : Centre "press right mouse key for options"
Timer=0
Repeat
If Mouse Key=1 Then Pop Proc
If Mouse Key=2 Then OPTIONS
If Asc(Inkey$)=27 Then End
Until Timer=400
HISCORE_DISPLAY
MWAIT[400]
Next I
Loop
End Proc